/**
 * 浏览器端作品详情响应类
 */
export class BrowserIllustResponse {
    /**
     * 是否错误
     * @type {boolean}
     */
    error;

    /**
     * 消息
     * @type {string}
     */
    message;

    /**
     * 响应主体
     * @type {BrowserIllustBody}
     */
    body;

    constructor(data) {
        this.error = data.error;
        this.message = data.message;
        this.body = new BrowserIllustBody(data.body);
    }
}

/**
 * 作品主体数据类
 */
export class BrowserIllustBody {
    /**
     * 作品ID
     * @type {string}
     */
    illustId;

    /**
     * 作品标题
     * @type {string}
     */
    illustTitle;

    /**
     * 作品评论
     * @type {string}
     */
    illustComment;

    /**
     * ID
     * @type {string}
     */
    id;

    /**
     * 标题
     * @type {string}
     */
    title;

    /**
     * 描述
     * @type {string}
     */
    description;

    /**
     * 作品类型
     * @type {number}
     */
    illustType;

    /**
     * 创建日期
     * @type {string}
     */
    createDate;

    /**
     * 上传日期
     * @type {string}
     */
    uploadDate;

    /**
     * 限制级别
     * @type {number}
     */
    restrict;

    /**
     * 年龄限制
     * @type {number}
     */
    xRestrict;

    /**
     * 健全度级别
     * @type {number}
     */
    sl;

    /**
     * 图片URL集合
     * @type {BrowserImageUrls}
     */
    urls;

    /**
     * 标签数据
     * @type {BrowserTags}
     */
    tags;

    /**
     * 替代文本
     * @type {string}
     */
    alt;

    /**
     * 用户ID
     * @type {string}
     */
    userId;

    /**
     * 用户名
     * @type {string}
     */
    userName;

    /**
     * 用户账号
     * @type {string}
     */
    userAccount;

    /**
     * 用户作品集
     * @type {BrowserUserIllusts}
     */
    userIllusts;

    /**
     * 点赞数据
     * @type {boolean}
     */
    likeData;

    /**
     * 宽度
     * @type {number}
     */
    width;

    /**
     * 高度
     * @type {number}
     */
    height;

    /**
     * 页数
     * @type {number}
     */
    pageCount;

    /**
     * 收藏数
     * @type {number}
     */
    bookmarkCount;

    /**
     * 点赞数
     * @type {number}
     */
    likeCount;

    /**
     * 评论数
     * @type {number}
     */
    commentCount;

    /**
     * 回复数
     * @type {number}
     */
    responseCount;

    /**
     * 查看数
     * @type {number}
     */
    viewCount;

    /**
     * 书籍样式
     * @type {string}
     */
    bookStyle;

    /**
     * 是否教程
     * @type {boolean}
     */
    isHowto;

    /**
     * 是否原创
     * @type {boolean}
     */
    isOriginal;

    /**
     * 图片响应输出数据
     * @type {Array}
     */
    imageResponseOutData;

    /**
     * 图片响应数据
     * @type {Array}
     */
    imageResponseData;

    /**
     * 图片响应数
     * @type {number}
     */
    imageResponseCount;

    /**
     * 投票数据
     * @type {Object|null}
     */
    pollData;

    /**
     * 系列导航数据
     * @type {Object|null}
     */
    seriesNavData;

    /**
     * 描述展位ID
     * @type {string|null}
     */
    descriptionBoothId;

    /**
     * 描述YouTube ID
     * @type {string|null}
     */
    descriptionYoutubeId;

    /**
     * 漫画推广
     * @type {Object|null}
     */
    comicPromotion;

    /**
     * Fanbox推广
     * @type {Object|null}
     */
    fanboxPromotion;

    /**
     * 比赛横幅
     * @type {BrowserContestData[]}
     */
    contestBanners;

    /**
     * 是否可收藏
     * @type {boolean}
     */
    isBookmarkable;

    /**
     * 收藏数据
     * @type {Object|null}
     */
    bookmarkData;

    /**
     * 比赛数据
     * @type {BrowserContestData[]}
     */
    contestData;

    /**
     * 区域配置
     * @type {BrowserZoneConfig}
     */
    zoneConfig;

    /**
     * 额外数据
     * @type {BrowserExtraData}
     */
    extraData;

    /**
     * 标题翻译
     * @type {Object}
     */
    titleCaptionTranslation;

    /**
     * 是否未列出
     * @type {boolean}
     */
    isUnlisted;

    /**
     * 请求数据
     * @type {Object|null}
     */
    request;

    /**
     * 评论关闭状态
     * @type {number}
     */
    commentOff;

    /**
     * AI类型
     * @type {number}
     */
    aiType;

    /**
     * 重新上传日期
     * @type {string|null}
     */
    reuploadDate;

    /**
     * 位置屏蔽
     * @type {boolean}
     */
    locationMask;

    /**
     * 委托链接隐藏
     * @type {boolean}
     */
    commissionLinkHidden;

    /**
     * 是否仅登录可见
     * @type {boolean}
     */
    isLoginOnly;

    /**
     * 非登录数据
     * @type {BrowserNoLoginData}
     */
    noLoginData;

    constructor(data) {
        this.illustId = data.illustId;
        this.illustTitle = data.illustTitle;
        this.illustComment = data.illustComment;
        this.id = data.id;
        this.title = data.title;
        this.description = data.description;
        this.illustType = data.illustType;
        this.createDate = data.createDate;
        this.uploadDate = data.uploadDate;
        this.restrict = data.restrict;
        this.xRestrict = data.xRestrict;
        this.sl = data.sl;
        this.urls = new BrowserImageUrls(data.urls);
        this.tags = new BrowserTags(data.tags);
        this.alt = data.alt;
        this.userId = data.userId;
        this.userName = data.userName;
        this.userAccount = data.userAccount;
        this.userIllusts = new BrowserUserIllusts(data.userIllusts);
        this.likeData = data.likeData;
        this.width = data.width;
        this.height = data.height;
        this.pageCount = data.pageCount;
        this.bookmarkCount = data.bookmarkCount;
        this.likeCount = data.likeCount;
        this.commentCount = data.commentCount;
        this.responseCount = data.responseCount;
        this.viewCount = data.viewCount;
        this.bookStyle = data.bookStyle;
        this.isHowto = data.isHowto;
        this.isOriginal = data.isOriginal;
        this.imageResponseOutData = data.imageResponseOutData;
        this.imageResponseData = data.imageResponseData;
        this.imageResponseCount = data.imageResponseCount;
        this.pollData = data.pollData;
        this.seriesNavData = data.seriesNavData;
        this.descriptionBoothId = data.descriptionBoothId;
        this.descriptionYoutubeId = data.descriptionYoutubeId;
        this.comicPromotion = data.comicPromotion;
        this.fanboxPromotion = data.fanboxPromotion;
        this.contestBanners = data.contestBanners.map(banner => new BrowserContestData(banner));
        this.isBookmarkable = data.isBookmarkable;
        this.bookmarkData = data.bookmarkData;
        this.contestData = data.contestData.map(contest => new BrowserContestData(contest));
        this.zoneConfig = new BrowserZoneConfig(data.zoneConfig);
        this.extraData = new BrowserExtraData(data.extraData);
        this.titleCaptionTranslation = data.titleCaptionTranslation;
        this.isUnlisted = data.isUnlisted;
        this.request = data.request;
        this.commentOff = data.commentOff;
        this.aiType = data.aiType;
        this.reuploadDate = data.reuploadDate;
        this.locationMask = data.locationMask;
        this.commissionLinkHidden = data.commissionLinkHidden;
        this.isLoginOnly = data.isLoginOnly;
        this.noLoginData = new BrowserNoLoginData(data.noLoginData);
    }
}

/**
 * 非登录数据类
 */
export class BrowserNoLoginData {
    /**
     * 面包屑导航
     * @type {Object}
     */
    breadcrumbs;

    /**
     * 前后作品ID
     * @type {Array}
     */
    zengoIdWorks;

    /**
     * 前后作品数据
     * @type {BrowserZengoWorkData}
     */
    zengoWorkData;

    constructor(data) {
        this.breadcrumbs = data.breadcrumbs;
        this.zengoIdWorks = data.zengoIdWorks.map(work => work ? new BrowserUserIllust(work) : null);
        this.zengoWorkData = new BrowserZengoWorkData(data.zengoWorkData);
    }
}

/**
 * 前后作品数据类
 */
export class BrowserZengoWorkData {
    /**
     * 下一个作品
     * @type {Object}
     */
    nextWork;

    /**
     * 上一个作品
     * @type {Object}
     */
    prevWork;

    constructor(data) {
        this.nextWork = data.nextWork;
        this.prevWork = data.prevWork;
    }
}

/**
 * 额外数据类
 */
export class BrowserExtraData {
    /**
     * 元数据
     * @type {BrowserMetaData}
     */
    meta;

    constructor(data) {
        this.meta = new BrowserMetaData(data.meta);
    }
}

/**
 * 元数据类
 */
export class BrowserMetaData {
    /**
     * 标题
     * @type {string}
     */
    title;

    /**
     * 描述
     * @type {string}
     */
    description;

    /**
     * 规范URL
     * @type {string}
     */
    canonical;

    /**
     * 替代语言
     * @type {Array}
     */
    alternateLanguages;

    /**
     * 描述头部
     * @type {string}
     */
    descriptionHeader;

    /**
     * OGP数据
     * @type {BrowserOgpData}
     */
    ogp;

    /**
     * Twitter数据
     * @type {BrowserTwitterData}
     */
    twitter;

    constructor(data) {
        this.title = data.title;
        this.description = data.description;
        this.canonical = data.canonical;
        this.alternateLanguages = data.alternateLanguages;
        this.descriptionHeader = data.descriptionHeader;
        this.ogp = new BrowserOgpData(data.ogp);
        this.twitter = new BrowserTwitterData(data.twitter);
    }
}

/**
 * 图片URL集合类
 */
export class BrowserImageUrls {
    /**
     * 迷你缩略图URL
     * @type {string|null}
     */
    mini;

    /**
     * 缩略图URL
     * @type {string|null}
     */
    thumb;

    /**
     * 小尺寸图片URL
     * @type {string|null}
     */
    small;

    /**
     * 常规尺寸图片URL
     * @type {string|null}
     */
    regular;

    /**
     * 原始尺寸图片URL
     * @type {string|null}
     */
    original;

    constructor(data) {
        this.mini = data.mini;
        this.thumb = data.thumb;
        this.small = data.small;
        this.regular = data.regular;
        this.original = data.original;
    }
}

/**
 * 标签类
 */
export class BrowserTag {
    /**
     * 标签名称
     * @type {string}
     */
    tag;

    /**
     * 是否锁定
     * @type {boolean}
     */
    locked;

    /**
     * 是否可删除
     * @type {boolean}
     */
    deletable;

    /**
     * 用户ID
     * @type {string|null}
     */
    userId;

    /**
     * 用户名
     * @type {string|null}
     */
    userName;

    constructor(data) {
        this.tag = data.tag;
        this.locked = data.locked;
        this.deletable = data.deletable;
        this.userId = data.userId || null;
        this.userName = data.userName || null;
    }
}

/**
 * 标签集合类
 */
export class BrowserTags {
    /**
     * 作者ID
     * @type {string}
     */
    authorId;

    /**
     * 是否锁定
     * @type {boolean}
     */
    isLocked;

    /**
     * 标签数组
     * @type {BrowserTag[]}
     */
    tags;

    /**
     * 是否可写
     * @type {boolean}
     */
    writable;

    constructor(data) {
        this.authorId = data.authorId;
        this.isLocked = data.isLocked;
        this.tags = data.tags.map(tag => new BrowserTag(tag));
        this.writable = data.writable;
    }
}

/**
 * 用户作品简要信息类
 */
export class BrowserUserIllust {
    /**
     * 作品ID
     * @type {string}
     */
    id;

    /**
     * 作品标题
     * @type {string}
     */
    title;

    /**
     * 作品类型
     * @type {number}
     */
    illustType;

    /**
     * 年龄限制
     * @type {number}
     */
    xRestrict;

    /**
     * 限制级别
     * @type {number}
     */
    restrict;

    /**
     * 健全度级别
     * @type {number}
     */
    sl;

    /**
     * 图片URL
     * @type {string}
     */
    url;

    /**
     * 作品描述
     * @type {string}
     */
    description;

    /**
     * 标签数组
     * @type {string[]}
     */
    tags;

    /**
     * 用户ID
     * @type {string}
     */
    userId;

    /**
     * 用户名
     * @type {string}
     */
    userName;

    /**
     * 图片宽度
     * @type {number}
     */
    width;

    /**
     * 图片高度
     * @type {number}
     */
    height;

    /**
     * 页数
     * @type {number}
     */
    pageCount;

    /**
     * 是否可收藏
     * @type {boolean}
     */
    isBookmarkable;

    /**
     * 收藏数据
     * @type {Object|null}
     */
    bookmarkData;

    /**
     * 替代文本
     * @type {string}
     */
    alt;

    /**
     * 标题翻译
     * @type {Object}
     */
    titleCaptionTranslation;

    /**
     * 创建日期
     * @type {string}
     */
    createDate;

    /**
     * 更新日期
     * @type {string}
     */
    updateDate;

    /**
     * 是否未列出
     * @type {boolean}
     */
    isUnlisted;

    /**
     * 是否被屏蔽
     * @type {boolean}
     */
    isMasked;

    /**
     * AI类型
     * @type {number}
     */
    aiType;

    /**
     * 头像URL
     * @type {string}
     */
    profileImageUrl;

    constructor(data) {
        if (!data) return;

        this.id = data.id;
        this.title = data.title;
        this.illustType = data.illustType;
        this.xRestrict = data.xRestrict;
        this.restrict = data.restrict;
        this.sl = data.sl;
        this.url = data.url;
        this.description = data.description;
        this.tags = data.tags;
        this.userId = data.userId;
        this.userName = data.userName;
        this.width = data.width;
        this.height = data.height;
        this.pageCount = data.pageCount;
        this.isBookmarkable = data.isBookmarkable;
        this.bookmarkData = data.bookmarkData;
        this.alt = data.alt;
        this.titleCaptionTranslation = data.titleCaptionTranslation;
        this.createDate = data.createDate;
        this.updateDate = data.updateDate;
        this.isUnlisted = data.isUnlisted;
        this.isMasked = data.isMasked;
        this.aiType = data.aiType;
        this.profileImageUrl = data.profileImageUrl;
    }
}

/**
 * 用户作品集合类
 */
export class BrowserUserIllusts {
    /**
     * 作品映射表
     * @type {Object.<string, BrowserUserIllust>}
     */
    illusts;

    constructor(data) {
        this.illusts = {};
        for (const key in data) {
            this.illusts[key] = data[key] ? new BrowserUserIllust(data[key]) : null;
        }
    }
}

/**
 * 比赛数据类
 */
export class BrowserContestData {
    /**
     * 比赛URL
     * @type {string}
     */
    url;

    /**
     * 图标URL
     * @type {string}
     */
    icon;

    /**
     * 比赛标题
     * @type {string}
     */
    title;

    constructor(data) {
        this.url = data.url;
        this.icon = data.icon;
        this.title = data.title;
    }
}

/**
 * 区域配置类
 */
export class BrowserZoneConfig {
    /**
     * 响应式配置
     * @type {Object}
     */
    responsive;

    /**
     * 矩形区域配置
     * @type {Object}
     */
    rectangle;

    /**
     * 500x500区域配置
     * @type {Object}
     */
    '500x500';

    /**
     * 头部区域配置
     * @type {Object}
     */
    header;

    /**
     * 底部区域配置
     * @type {Object}
     */
    footer;

    /**
     * 扩展底部配置
     * @type {Object}
     */
    expandedFooter;

    /**
     * Logo区域配置
     * @type {Object}
     */
    logo;

    /**
     * 广告Logo配置
     * @type {Object}
     */
    ad_logo;

    /**
     * 相关作品配置
     * @type {Object}
     */
    relatedworks;

    constructor(data) {
        this.responsive = data.responsive;
        this.rectangle = data.rectangle;
        this['500x500'] = data['500x500'];
        this.header = data.header;
        this.footer = data.footer;
        this.expandedFooter = data.expandedFooter;
        this.logo = data.logo;
        this.ad_logo = data.ad_logo;
        this.relatedworks = data.relatedworks;
    }
}

/**
 * OGP数据类
 */
export class BrowserOgpData {
    /**
     * 描述
     * @type {string}
     */
    description;

    /**
     * 图片URL
     * @type {string}
     */
    image;

    /**
     * 标题
     * @type {string}
     */
    title;

    /**
     * 类型
     * @type {string}
     */
    type;

    constructor(data) {
        this.description = data.description;
        this.image = data.image;
        this.title = data.title;
        this.type = data.type;
    }
}

/**
 * Twitter数据类
 */
export class BrowserTwitterData {
    /**
     * 描述
     * @type {string}
     */
    description;

    /**
     * 图片URL
     * @type {string}
     */
    image;

    /**
     * 标题
     * @type {string}
     */
    title;

    /**
     * 卡片类型
     * @type {string}
     */
    card;

    constructor(data) {
        this.description = data.description;
        this.image = data.image;
        this.title = data.title;
        this.card = data.card;
    }
}
